﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BlackBird : Bird
{
    private List<Enemy> goods = new List<Enemy>(); //需要new创建实例才能使用它的方法，直接赋值不需要new

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "enemy")
        {
            goods.Add(collision.gameObject.GetComponent<Enemy>());
        }
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "enemy")
        {
            goods.Remove(collision.gameObject.GetComponent<Enemy>());
        }
    }

    protected override void UseSkill()
    {
        if(goods.Count > 0)
        {
            for (int i = 0;i <goods.Count; i++)
            {
                goods[i].Dead();
            }
        }
        GetComponent<CircleCollider2D>().enabled = false;
        BirdDead();
    }

    protected override void BirdDead()
    {
        rb.velocity = Vector3.zero;  //停止运动
        base.BirdDead();
    }

}
